# 作者：小七
# 2024年12月27日

def check_type():
    s1 = 'abc123'
    print(s1.isalnum())
    s2 = '123'
    print(s2.isdecimal())
    s3 = 'abc'
    print(s3.isalpha())


def str_find():
    s1 = 'abcdefgcdef'
    print(s1.find('c', 4))
    s2 = s1.replace('cd', 'CD', 1)
    print(s2)


def str_split_join():
    s1 = 'abc bcd 哈哈哈'
    print(s1.split())
    s1 = 'abc,bcd,哈哈哈'
    print(s1.split(','))
    s2 = 'abc\nbcd\nef'
    print(s2.splitlines())

    print('-' * 50)
    s3 = 'abc\r\nbcd\r\nef'
    print(s3.splitlines(True))
    print('-' * 50)
    str_list = ['a', 'b', 'c', 'd', 'e']
    print(''.join(str_list))


def study_r():
    print('abc\rd')
    print('abc\r\nd')


def str_slice():
    num_str = "0123456789"

    print(num_str[2:6])
    print(num_str[2:])
    print(num_str[:6])
    print(num_str[:])
    print(num_str[::2])
    print(num_str[1::2])
    print(num_str[2:-1])
    print(num_str[-2:])
    print(num_str[::-1])


def list_slice():
    my_list = list("123456789")
    print(my_list)
    print([int(i) for i in my_list])
    print(my_list[2:6])


def index_count():
    hello_str = "hello hello"

    print(len(hello_str))

    print(hello_str.count("llo"))
    print(hello_str.count("abc"))

    print(hello_str.index("llo"))
    # print(hello_str.index("abc"))


if __name__ == '__main__':
    # check_type()
    # str_find()
    # str_split_join()
    # study_r()
    # str_slice()
    # list_slice()
    index_count()